/**
 * Copyright (C) 2018-2021
 * All rights reserved, Designed By www.yixiang.co

 */
package co.yixiang.modules.product.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.domain.BaseDomain;
import co.yixiang.modules.category.domain.YxStoreCategory;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.*;
import java.math.BigDecimal;

/**
* @author hupeng
* @date 2020-05-12
*/


@TableName("yx_store_product")
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class YxStoreProduct extends BaseDomain {

    /** 商品id */
    @TableId
    @ApiModelProperty(value = "商品ID")
    private Long id;


    /** 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) */
    @ApiModelProperty(value = "商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) 预留字段")
    private Integer merId;


    /** 商品图片 */
    @NotBlank(message = "请上传商品图片")
    @ApiModelProperty(value = "商品图片")
    private String image;


    /** 轮播图 */
    @NotBlank(message = "请上传商品轮播图")
    @ApiModelProperty(value = "商品轮播图")
    private String sliderImage;


    /** 商品名称 */
    @NotBlank(message = "商品名称不能空")
    @ApiModelProperty(value = "商品名称")
    private String storeName;


    /** 商品简介 */
    @ApiModelProperty(value = "商品简介")
    private String storeInfo;


    /** 关键字 */
    @ApiModelProperty(value = "关键字")
    private String keyword;


    /** 产品条码（一维码） */
    @ApiModelProperty(value = "产品条码（一维码）")
    private String barCode;


    /** 分类id */
    @ApiModelProperty(value = "分类id")
    private String cateId;


    /** 商品价格 */
    @ApiModelProperty(value = "商品价格")
    @NotNull(message = "请输入商品价格")
    @DecimalMin(value="0.00", message = "商品价格不在合法范围内" )
    @DecimalMax(value="99999999.99", message = "商品价格不在合法范围内")
    private BigDecimal price;


    /** 会员价格 */
    @ApiModelProperty(value = "会员价格")
    private BigDecimal vipPrice;


    /** 市场价 */
    @ApiModelProperty(value = "市场价")
    @NotNull(message = "请输入市场价")
    @DecimalMin(value="0.00", message = "市场价不在合法范围内" )
    @DecimalMax(value="99999999.99", message = "市场价不在合法范围内")
    private BigDecimal otPrice;


    /** 邮费 */
    @ApiModelProperty(value = "邮费")
    private BigDecimal postage;


    /** 单位名 */
    @NotBlank(message = "请填写单位")
    @ApiModelProperty(value = "单位名")
    private String unitName;


    /** 排序 */
    @ApiModelProperty(value = "排序")
    private Integer sort;


    /** 销量 */
    @ApiModelProperty(value = "销量")
    private Integer sales;


    /** 库存 */
    @ApiModelProperty(value = "库存")
    @NotNull(message = "请输入库存")
    @Min(message = "库存不能小于0",value = 1)
    private Integer stock;


    /** 需要多少积分兑换 */
    @ApiModelProperty(value = "需要多少积分兑换 只在开启积分兑换时生效")
    private Integer integral;


    /** 状态（0：未上架，1：上架） */
    @ApiModelProperty(value = "状态（0：未上架，1：上架）")
    private Integer isShow;


    /** 是否热卖 */
    @ApiModelProperty(value = "是否热卖（0：否，1：是）")
    private Integer isHot;


    /** 是否优惠 */
    @ApiModelProperty(value = "是否猜你喜欢（0：否，1：是）")
    private Integer isBenefit;


    /** 是否精品 */
    @ApiModelProperty(value = "是否精品（0：否，1：是）")
    private Integer isBest;


    /** 是否新品 */
    @ApiModelProperty(value = "是否新品（0：否，1：是）")
    private Integer isNew;


    /** 产品描述 */
    @NotBlank(message = "请填写商品详情")
    @ApiModelProperty(value = "商品详情")
    private String description;


    /** 是否包邮 */
    @ApiModelProperty(value = "是否包邮")
    private Integer isPostage;


    /** 商户是否代理 0不可代理1可代理 */
    @ApiModelProperty(value = "商户是否代理 0不可代理1可代理 ")
    private Integer merUse;


    /** 获得积分 */
    @ApiModelProperty(value = "获得积分")
    @DecimalMin(value="0.00", message = "获得积分不在合法范围内" )
    @DecimalMax(value="99999999.99", message = "获得积分不在合法范围内")
    private BigDecimal giveIntegral;


    /** 成本价 */
    @ApiModelProperty(value = "成本价")
    @NotNull(message = "请输入成本价")
    @DecimalMin(value="0.00", message = "成本价不在合法范围内" )
    @DecimalMax(value="99999999.99", message = "成本价不在合法范围内")
    private BigDecimal cost;


    /** 秒杀状态 0 未开启 1已开启 */
    @ApiModelProperty(value = "秒杀状态 0 未开启 1已开启")
    private Integer isSeckill;


    /** 砍价状态 0未开启 1开启 */
    @ApiModelProperty(value = "砍价状态 0 未开启 1已开启")
    private Integer isBargain;


    /** 是否优品推荐 */
    @ApiModelProperty(value = "是否优品推荐（0：否，1：是）")
    private Integer isGood;


    /** 虚拟销量 */
    @ApiModelProperty(value = "虚拟销量")
    private Integer ficti;


    /** 浏览量 */
    @ApiModelProperty(value = "浏览量")
    private Integer browse;


    /** 产品二维码地址(用户小程序海报) */
    @ApiModelProperty(value = "品二维码地址(用户小程序海报) ")
    private String codePath;

    @ApiModelProperty(value = "邮费模版ID")
    private Integer tempId;

    @ApiModelProperty(value = "规格 0单 1多 ")
    private Integer specType;

    @ApiModelProperty(value = "是否单独分佣")
    private Integer isSub;

    @ApiModelProperty(value = "是否开启积分兑换")
    private Integer isIntegral;

    @TableField(exist = false)
    private YxStoreCategory storeCategory;

    public static YxStoreProductBuilder builder() {
        return new YxStoreProductBuilder();
    }


    public void copy(YxStoreProduct source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static class YxStoreProductBuilder {
        private Long id;
        private Integer merId;
        private @NotBlank(message = "请上传商品图片") String image;
        private @NotBlank(message = "请上传商品轮播图") String sliderImage;
        private @NotBlank(message = "商品名称不能空") String storeName;
        private String storeInfo;
        private String keyword;
        private String barCode;
        private String cateId;
        private @NotNull(message = "请输入商品价格") @DecimalMin(value = "0.00", message = "商品价格不在合法范围内") @DecimalMax(value = "99999999.99", message = "商品价格不在合法范围内") BigDecimal price;
        private BigDecimal vipPrice;
        private @NotNull(message = "请输入市场价") @DecimalMin(value = "0.00", message = "市场价不在合法范围内") @DecimalMax(value = "99999999.99", message = "市场价不在合法范围内") BigDecimal otPrice;
        private BigDecimal postage;
        private @NotBlank(message = "请填写单位") String unitName;
        private Integer sort;
        private Integer sales;
        private @NotNull(message = "请输入库存") @Min(message = "库存不能小于0", value = 1) Integer stock;
        private Integer integral;
        private Integer isShow;
        private Integer isHot;
        private Integer isBenefit;
        private Integer isBest;
        private Integer isNew;
        private @NotBlank(message = "请填写商品详情") String description;
        private Integer isPostage;
        private Integer merUse;
        private @DecimalMin(value = "0.00", message = "获得积分不在合法范围内") @DecimalMax(value = "99999999.99", message = "获得积分不在合法范围内") BigDecimal giveIntegral;
        private @NotNull(message = "请输入成本价") @DecimalMin(value = "0.00", message = "成本价不在合法范围内") @DecimalMax(value = "99999999.99", message = "成本价不在合法范围内") BigDecimal cost;
        private Integer isSeckill;
        private Integer isBargain;
        private Integer isGood;
        private Integer ficti;
        private Integer browse;
        private String codePath;
        private Integer tempId;
        private Integer specType;
        private Integer isSub;
        private Integer isIntegral;
        private YxStoreCategory storeCategory;

        YxStoreProductBuilder() {
        }

        public YxStoreProductBuilder id(Long id) {
            this.id = id;
            return this;
        }

        public YxStoreProductBuilder merId(Integer merId) {
            this.merId = merId;
            return this;
        }

        public YxStoreProductBuilder image(@NotBlank(message = "请上传商品图片") String image) {
            this.image = image;
            return this;
        }

        public YxStoreProductBuilder sliderImage(@NotBlank(message = "请上传商品轮播图") String sliderImage) {
            this.sliderImage = sliderImage;
            return this;
        }

        public YxStoreProductBuilder storeName(@NotBlank(message = "商品名称不能空") String storeName) {
            this.storeName = storeName;
            return this;
        }

        public YxStoreProductBuilder storeInfo(String storeInfo) {
            this.storeInfo = storeInfo;
            return this;
        }

        public YxStoreProductBuilder keyword(String keyword) {
            this.keyword = keyword;
            return this;
        }

        public YxStoreProductBuilder barCode(String barCode) {
            this.barCode = barCode;
            return this;
        }

        public YxStoreProductBuilder cateId(String cateId) {
            this.cateId = cateId;
            return this;
        }

        public YxStoreProductBuilder price(@NotNull(message = "请输入商品价格") @DecimalMin(value = "0.00", message = "商品价格不在合法范围内") @DecimalMax(value = "99999999.99", message = "商品价格不在合法范围内") BigDecimal price) {
            this.price = price;
            return this;
        }

        public YxStoreProductBuilder vipPrice(BigDecimal vipPrice) {
            this.vipPrice = vipPrice;
            return this;
        }

        public YxStoreProductBuilder otPrice(@NotNull(message = "请输入市场价") @DecimalMin(value = "0.00", message = "市场价不在合法范围内") @DecimalMax(value = "99999999.99", message = "市场价不在合法范围内") BigDecimal otPrice) {
            this.otPrice = otPrice;
            return this;
        }

        public YxStoreProductBuilder postage(BigDecimal postage) {
            this.postage = postage;
            return this;
        }

        public YxStoreProductBuilder unitName(@NotBlank(message = "请填写单位") String unitName) {
            this.unitName = unitName;
            return this;
        }

        public YxStoreProductBuilder sort(Integer sort) {
            this.sort = sort;
            return this;
        }

        public YxStoreProductBuilder sales(Integer sales) {
            this.sales = sales;
            return this;
        }

        public YxStoreProductBuilder stock(@NotNull(message = "请输入库存") @Min(message = "库存不能小于0", value = 1) Integer stock) {
            this.stock = stock;
            return this;
        }

        public YxStoreProductBuilder integral(Integer integral) {
            this.integral = integral;
            return this;
        }

        public YxStoreProductBuilder isShow(Integer isShow) {
            this.isShow = isShow;
            return this;
        }

        public YxStoreProductBuilder isHot(Integer isHot) {
            this.isHot = isHot;
            return this;
        }

        public YxStoreProductBuilder isBenefit(Integer isBenefit) {
            this.isBenefit = isBenefit;
            return this;
        }

        public YxStoreProductBuilder isBest(Integer isBest) {
            this.isBest = isBest;
            return this;
        }

        public YxStoreProductBuilder isNew(Integer isNew) {
            this.isNew = isNew;
            return this;
        }

        public YxStoreProductBuilder description(@NotBlank(message = "请填写商品详情") String description) {
            this.description = description;
            return this;
        }

        public YxStoreProductBuilder isPostage(Integer isPostage) {
            this.isPostage = isPostage;
            return this;
        }

        public YxStoreProductBuilder merUse(Integer merUse) {
            this.merUse = merUse;
            return this;
        }

        public YxStoreProductBuilder giveIntegral(@DecimalMin(value = "0.00", message = "获得积分不在合法范围内") @DecimalMax(value = "99999999.99", message = "获得积分不在合法范围内") BigDecimal giveIntegral) {
            this.giveIntegral = giveIntegral;
            return this;
        }

        public YxStoreProductBuilder cost(@NotNull(message = "请输入成本价") @DecimalMin(value = "0.00", message = "成本价不在合法范围内") @DecimalMax(value = "99999999.99", message = "成本价不在合法范围内") BigDecimal cost) {
            this.cost = cost;
            return this;
        }

        public YxStoreProductBuilder isSeckill(Integer isSeckill) {
            this.isSeckill = isSeckill;
            return this;
        }

        public YxStoreProductBuilder isBargain(Integer isBargain) {
            this.isBargain = isBargain;
            return this;
        }

        public YxStoreProductBuilder isGood(Integer isGood) {
            this.isGood = isGood;
            return this;
        }

        public YxStoreProductBuilder ficti(Integer ficti) {
            this.ficti = ficti;
            return this;
        }

        public YxStoreProductBuilder browse(Integer browse) {
            this.browse = browse;
            return this;
        }

        public YxStoreProductBuilder codePath(String codePath) {
            this.codePath = codePath;
            return this;
        }

        public YxStoreProductBuilder tempId(Integer tempId) {
            this.tempId = tempId;
            return this;
        }

        public YxStoreProductBuilder specType(Integer specType) {
            this.specType = specType;
            return this;
        }

        public YxStoreProductBuilder isSub(Integer isSub) {
            this.isSub = isSub;
            return this;
        }

        public YxStoreProductBuilder isIntegral(Integer isIntegral) {
            this.isIntegral = isIntegral;
            return this;
        }

        public YxStoreProductBuilder storeCategory(YxStoreCategory storeCategory) {
            this.storeCategory = storeCategory;
            return this;
        }

        public YxStoreProduct build() {
            return new YxStoreProduct(id, merId, image, sliderImage, storeName, storeInfo, keyword, barCode, cateId, price, vipPrice, otPrice, postage, unitName, sort, sales, stock, integral, isShow, isHot, isBenefit, isBest, isNew, description, isPostage, merUse, giveIntegral, cost, isSeckill, isBargain, isGood, ficti, browse, codePath, tempId, specType, isSub, isIntegral, storeCategory);
        }

        public String toString() {
            return "YxStoreProduct.YxStoreProductBuilder(id=" + this.id + ", merId=" + this.merId + ", image=" + this.image + ", sliderImage=" + this.sliderImage + ", storeName=" + this.storeName + ", storeInfo=" + this.storeInfo + ", keyword=" + this.keyword + ", barCode=" + this.barCode + ", cateId=" + this.cateId + ", price=" + this.price + ", vipPrice=" + this.vipPrice + ", otPrice=" + this.otPrice + ", postage=" + this.postage + ", unitName=" + this.unitName + ", sort=" + this.sort + ", sales=" + this.sales + ", stock=" + this.stock + ", integral=" + this.integral + ", isShow=" + this.isShow + ", isHot=" + this.isHot + ", isBenefit=" + this.isBenefit + ", isBest=" + this.isBest + ", isNew=" + this.isNew + ", description=" + this.description + ", isPostage=" + this.isPostage + ", merUse=" + this.merUse + ", giveIntegral=" + this.giveIntegral + ", cost=" + this.cost + ", isSeckill=" + this.isSeckill + ", isBargain=" + this.isBargain + ", isGood=" + this.isGood + ", ficti=" + this.ficti + ", browse=" + this.browse + ", codePath=" + this.codePath + ", tempId=" + this.tempId + ", specType=" + this.specType + ", isSub=" + this.isSub + ", isIntegral=" + this.isIntegral + ", storeCategory=" + this.storeCategory + ")";
        }
    }
}
